From ada588411f0ee53081fa6054e073089a4aa6cc4f Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Tue, 20 Feb 2007 16:30:24 +0000 Subject: [PATCH] Remove VM.VCPUs_number and VM.VCPUs_utilisation as these have moved onto the VM_metrics class. Remove VM_metrics.VM -- the backreference is unnecessary and awkward to deal with. Signed-off-by: Ewan Mellor --- docs/xen-api/xenapi-datamodel.tex | 102 +------------------------- tools/libxen/include/xen_vm_metrics.h | 11 +-- tools/libxen/src/xen_vm_metrics.c | 24 +----- tools/libxen/test/test_bindings.c | 42 +++++++++-- 4 files changed, 38 insertions(+), 141 deletions(-) diff --git a/docs/xen-api/xenapi-datamodel.tex b/docs/xen-api/xenapi-datamodel.tex index e7705754d1..2d52fa7022 100644 --- a/docs/xen-api/xenapi-datamodel.tex +++ b/docs/xen-api/xenapi-datamodel.tex @@ -61,7 +61,6 @@ VIF.VM & VM.VIFs & one-to-many\\ VIF.network & network.VIFs & one-to-many\\ host.metrics & host\_metrics.host & one-to-one\\ PIF.metrics & PIF\_metrics.PIF & one-to-one\\ -VM.metrics & VM\_metrics.VM & one-to-one\\ PIF.host & host.PIFs & one-to-many\\ PIF.network & network.PIFs & one-to-many\\ SR.VDIs & VDI.SR & many-to-one\\ @@ -1076,8 +1075,6 @@ $\mathit{RW}$ & {\tt VCPUs/policy} & string & the name of the VCPU scheduling p $\mathit{RW}$ & {\tt VCPUs/params} & (string $\rightarrow$ string) Map & configuration parameters for the selected VCPU policy \\ $\mathit{RW}$ & {\tt VCPUs/max} & int & Max number of VCPUs \\ $\mathit{RW}$ & {\tt VCPUs/at\_startup} & int & Boot number of VCPUs \\ -$\mathit{RO}_\mathit{ins}$ & {\tt VCPUs/number} & int & Current number of VCPUs \\ -$\mathit{RO}_\mathit{run}$ & {\tt VCPUs/utilisation} & (int $\rightarrow$ float) Map & Utilisation for all of guest's current VCPUs \\ $\mathit{RW}$ & {\tt actions/after\_shutdown} & on\_normal\_exit & action to take after the guest has shutdown itself \\ $\mathit{RW}$ & {\tt actions/after\_reboot} & on\_normal\_exit & action to take after the guest has rebooted itself \\ $\mathit{RW}$ & {\tt actions/after\_crash} & on\_crash\_behaviour & action to take if the guest crashes \\ @@ -1102,7 +1099,7 @@ $\mathit{RO}_\mathit{ins}$ & {\tt PCI\_bus} & string & PCI bus path for pass-th $\mathit{RO}_\mathit{run}$ & {\tt tools\_version} & (string $\rightarrow$ string) Map & versions of installed paravirtualised drivers \\ $\mathit{RW}$ & {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\ $\mathit{RO}_\mathit{run}$ & {\tt is\_control\_domain} & bool & true if this is a control domain (domain 0 or a driver domain) \\ -$\mathit{RO}_\mathit{ins}$ & {\tt metrics} & VM\_metrics ref & metrics associated with this VM. \\ +$\mathit{RO}_\mathit{run}$ & {\tt metrics} & VM\_metrics ref & metrics associated with this VM. \\ \hline \end{longtable} \subsection{Additional RPCs associated with class: VM} @@ -2545,70 +2542,6 @@ void -\vspace{0.3cm} -\vspace{0.3cm} -\vspace{0.3cm} -\subsubsection{RPC name:~get\_VCPUs\_number} - -{\bf Overview:} -Get the VCPUs/number field of the given VM. - - \noindent {\bf Signature:} -\begin{verbatim} int get_VCPUs_number (session_id s, VM ref self)\end{verbatim} - - -\noindent{\bf Arguments:} - - -\vspace{0.3cm} -\begin{tabular}{|c|c|p{7cm}|} - \hline -{\bf type} & {\bf name} & {\bf description} \\ \hline -{\tt VM ref } & self & reference to the object \\ \hline - -\end{tabular} - -\vspace{0.3cm} - - \noindent {\bf Return Type:} -{\tt -int -} - - -value of the field -\vspace{0.3cm} -\vspace{0.3cm} -\vspace{0.3cm} -\subsubsection{RPC name:~get\_VCPUs\_utilisation} - -{\bf Overview:} -Get the VCPUs/utilisation field of the given VM. - - \noindent {\bf Signature:} -\begin{verbatim} ((int -> float) Map) get_VCPUs_utilisation (session_id s, VM ref self)\end{verbatim} - - -\noindent{\bf Arguments:} - - -\vspace{0.3cm} -\begin{tabular}{|c|c|p{7cm}|} - \hline -{\bf type} & {\bf name} & {\bf description} \\ \hline -{\tt VM ref } & self & reference to the object \\ \hline - -\end{tabular} - -\vspace{0.3cm} - - \noindent {\bf Return Type:} -{\tt -(int $\rightarrow$ float) Map -} - - -value of the field \vspace{0.3cm} \vspace{0.3cm} \vspace{0.3cm} @@ -4273,7 +4206,6 @@ The metrics associated with a VM.}} \\ Quals & Field & Type & Description \\ \hline $\mathit{RO}_\mathit{run}$ & {\tt uuid} & string & unique identifier/object reference \\ -$\mathit{RO}_\mathit{ins}$ & {\tt VM} & VM ref & VM to which these metrics apply \\ $\mathit{RO}_\mathit{run}$ & {\tt memory/actual} & int & Guest's actual memory (bytes) \\ $\mathit{RO}_\mathit{run}$ & {\tt VCPUs/number} & int & Current number of VCPUs \\ $\mathit{RO}_\mathit{run}$ & {\tt VCPUs/utilisation} & (int $\rightarrow$ float) Map & Utilisation for all of guest's current VCPUs \\ @@ -4308,38 +4240,6 @@ string } -value of the field -\vspace{0.3cm} -\vspace{0.3cm} -\vspace{0.3cm} -\subsubsection{RPC name:~get\_VM} - -{\bf Overview:} -Get the VM field of the given VM\_metrics. - - \noindent {\bf Signature:} -\begin{verbatim} (VM ref) get_VM (session_id s, VM_metrics ref self)\end{verbatim} - - -\noindent{\bf Arguments:} - - -\vspace{0.3cm} -\begin{tabular}{|c|c|p{7cm}|} - \hline -{\bf type} & {\bf name} & {\bf description} \\ \hline -{\tt VM\_metrics ref } & self & reference to the object \\ \hline - -\end{tabular} - -\vspace{0.3cm} - - \noindent {\bf Return Type:} -{\tt -VM ref -} - - value of the field \vspace{0.3cm} \vspace{0.3cm} diff --git a/tools/libxen/include/xen_vm_metrics.h b/tools/libxen/include/xen_vm_metrics.h index 740e327d10..e3b06c214b 100644 --- a/tools/libxen/include/xen_vm_metrics.h +++ b/tools/libxen/include/xen_vm_metrics.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, XenSource Inc. + * Copyright (c) 2006-2007, XenSource Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -21,7 +21,6 @@ #include "xen_common.h" #include "xen_int_float_map.h" -#include "xen_vm_decl.h" #include "xen_vm_metrics_decl.h" @@ -64,7 +63,6 @@ typedef struct xen_vm_metrics_record { xen_vm_metrics handle; char *uuid; - struct xen_vm_record_opt *vm; int64_t memory_actual; int64_t vcpus_number; xen_int_float_map *vcpus_utilisation; @@ -170,13 +168,6 @@ extern bool xen_vm_metrics_get_uuid(xen_session *session, char **result, xen_vm_metrics vm_metrics); -/** - * Get the VM field of the given VM_metrics. - */ -extern bool -xen_vm_metrics_get_vm(xen_session *session, xen_vm *result, xen_vm_metrics vm_metrics); - - /** * Get the memory/actual field of the given VM_metrics. */ diff --git a/tools/libxen/src/xen_vm_metrics.c b/tools/libxen/src/xen_vm_metrics.c index 03a08d8971..6f5e95166e 100644 --- a/tools/libxen/src/xen_vm_metrics.c +++ b/tools/libxen/src/xen_vm_metrics.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, XenSource Inc. + * Copyright (c) 2006-2007, XenSource Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -23,7 +23,6 @@ #include "xen_common.h" #include "xen_int_float_map.h" #include "xen_internal.h" -#include "xen_vm.h" #include "xen_vm_metrics.h" @@ -41,9 +40,6 @@ static const struct_member xen_vm_metrics_record_struct_members[] = { .key = "uuid", .type = &abstract_type_string, .offset = offsetof(xen_vm_metrics_record, uuid) }, - { .key = "VM", - .type = &abstract_type_ref, - .offset = offsetof(xen_vm_metrics_record, vm) }, { .key = "memory_actual", .type = &abstract_type_int, .offset = offsetof(xen_vm_metrics_record, memory_actual) }, @@ -74,7 +70,6 @@ xen_vm_metrics_record_free(xen_vm_metrics_record *record) } free(record->handle); free(record->uuid); - xen_vm_record_opt_free(record->vm); xen_int_float_map_free(record->vcpus_utilisation); free(record); } @@ -120,23 +115,6 @@ xen_vm_metrics_get_by_uuid(xen_session *session, xen_vm_metrics *result, char *u } -bool -xen_vm_metrics_get_vm(xen_session *session, xen_vm *result, xen_vm_metrics vm_metrics) -{ - abstract_value param_values[] = - { - { .type = &abstract_type_string, - .u.string_val = vm_metrics } - }; - - abstract_type result_type = abstract_type_string; - - *result = NULL; - XEN_CALL_("VM_metrics.get_VM"); - return session->ok; -} - - bool xen_vm_metrics_get_memory_actual(xen_session *session, int64_t *result, xen_vm_metrics vm_metrics) { diff --git a/tools/libxen/test/test_bindings.c b/tools/libxen/test/test_bindings.c index c1df98dcea..90d33e4ff8 100644 --- a/tools/libxen/test/test_bindings.c +++ b/tools/libxen/test/test_bindings.c @@ -31,6 +31,7 @@ #include "xen_vdi.h" #include "xen_console.h" #include "xen_vm.h" +#include "xen_vm_metrics.h" static void usage() @@ -61,6 +62,7 @@ typedef struct static xen_vm create_new_vm(xen_session *session, bool hvm); static void print_vm_power_state(xen_session *session, xen_vm vm); +static void print_vm_metrics(xen_session *session, xen_vm vm); static size_t @@ -245,12 +247,7 @@ int main(int argc, char **argv) printf("%s.\n", xen_vm_power_state_to_string(vm_record->power_state)); - for (size_t i = 0; i < vm_record->vcpus_utilisation->size; i++) - { - printf("%"PRId64" -> %lf.\n", - vm_record->vcpus_utilisation->contents[i].key, - vm_record->vcpus_utilisation->contents[i].val); - } + print_vm_metrics(session, vm); xen_uuid_bytes_free(vm_uuid_bytes); xen_uuid_free(vm_uuid); @@ -323,7 +320,6 @@ static xen_vm create_new_vm(xen_session *session, bool hvm) .memory_static_min = 128, .vcpus_policy = "credit", .vcpus_params = vcpus_params, - .vcpus_number = 2, .actions_after_shutdown = XEN_ON_NORMAL_EXIT_DESTROY, .actions_after_reboot = XEN_ON_NORMAL_EXIT_RESTART, .actions_after_crash = XEN_ON_CRASH_BEHAVIOUR_PRESERVE, @@ -519,3 +515,35 @@ static void print_vm_power_state(xen_session *session, xen_vm vm) xen_uuid_free(vm_uuid); } + + +/** + * Print the metrics for the given VM. + */ +static void print_vm_metrics(xen_session *session, xen_vm vm) +{ + xen_vm_metrics vm_metrics; + if (!xen_vm_get_metrics(session, &vm_metrics, vm)) + { + print_error(session); + return; + } + + xen_vm_metrics_record *vm_metrics_record; + if (!xen_vm_metrics_get_record(session, &vm_metrics_record, vm_metrics)) + { + xen_vm_metrics_free(vm_metrics); + print_error(session); + return; + } + + for (size_t i = 0; i < vm_metrics_record->vcpus_utilisation->size; i++) + { + printf("%"PRId64" -> %lf.\n", + vm_metrics_record->vcpus_utilisation->contents[i].key, + vm_metrics_record->vcpus_utilisation->contents[i].val); + } + + xen_vm_metrics_record_free(vm_metrics_record); + xen_vm_metrics_free(vm_metrics); +} -- 2.30.2